commands/test: Stack overflow due to unlimited recursion depth
authorLidong Chen <lidong.chen@oracle.com>
Mon, 16 Dec 2024 20:22:41 +0000 (20:22 +0000)
committerMiao Wang <shankerwangmiao@gmail.com>
Sun, 15 Feb 2026 13:50:20 +0000 (13:50 +0000)
commit1bec43905f9f922cdaa52b1a55649a540a51495a
treeb2eca0f59dc845cddab6de778f85bb352bc45bed
parent9d2de8159287c08f3cf5dbb14435761afbc2084f
commands/test: Stack overflow due to unlimited recursion depth

The test_parse() evaluates test expression recursively. Due to lack of
recursion depth check a specially crafted expression may cause a stack
overflow. The recursion is only triggered by the parentheses usage and
it can be unlimited. However, sensible expressions are unlikely to
contain more than a few parentheses. So, this patch limits the recursion
depth to 100, which should be sufficient.

Reported-by: Nils Langius <nils@langius.de>
Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Gbp-Pq: Topic cve-2025-jan
Gbp-Pq: Name commands-test-Stack-overflow-due-to-unlimited-recursion-d.patch
grub-core/commands/test.c